<template>
  <div class="resume-info editabled">
    <div class="resume-info-left" v-if="data.id">
      <div class="resume-title">
        <!-- 真诚求职一份工作真诚求职一份工作真诚求职一份工作标题（标题三十五个字） -->
        <el-input type="text" class="font20" v-model="data.resumeTitle" :maxlength="35"></el-input>
      </div>
      <div class="resume-user-info weigui-wrap">
        <div class="weigui" v-if="weig" @click="weigui">
          <img class="img" src="@/assets/v3/new-weigui.png" />

          <p>该用户有{{ Count }}条违规信息！</p>
          <div>查看详情</div>
        </div>
        <div class="resume-user-left">
          <div class="resume-user-detail" :class="''">
            <span>姓名：
              <!-- 林依依 -->
              {{ data.realName }}
            </span>
            <span>
              {{ data.sexualDistinction == 1 ? "男" : "女" }}
            </span>

            <span>{{ data.age }}</span>
            <span>{{ (data.highestEducation || "").split(" ")[0] }}学历</span>
          </div>
          <div class="resume-user-ex" :class="''" v-if="data.experienceYears">
            {{ data.experienceYears }}年工作经验
          </div>
          <div class="resume-user-add" :class="''" v-if="data.homeAddress">
            地址:
            <!-- 湖北省武汉市洪山区光谷创业街9栋 -->
            {{ data.homeAddress }}
          </div>
        </div>
        <img v-if="data.myPhoto" :src="data.myPhoto" class="resume-user-right" :class="''" />
      </div>

      <div class="seperate"></div>
      <dl>
        <dt class="title left-icon" style="margin-top: 18px">教育经历</dt>
        <template v-for="(item, index) in data.graduationAcademy || []">
          <dl :key="index" :class="''">
            <dd>
              <span style="margin-right: 133px">{{
                (data.highestEducation || "").split(" ")[0]
              }}</span>
              <span>{{ item.schoolHours }}</span>
            </dd>
            <dd>
              <span>{{ item.schoolName }}</span>
              <span>{{ item.major }}</span>
            </dd>
          </dl>
        </template>

        <dt class="title left-icon" style="margin-bottom: 10px">工作经历</dt>
        <template v-for="(i, index) in workExperience || []">
          <dl :key="index" class="border">
            <dd style="margin-top: 0">
              <span style="margin-right: 40px">{{ i.corporateName }}</span>
              <span>{{ i.onJobTime.split("|").join("-") }}</span>
            </dd>
            <dd>
              <span>{{ i.positionName }}</span>
            </dd>
            <dd>工作内容：{{ i.jobContent }}</dd>
            <div class="new-operation">
              <i class="el-icon-edit" @click.stop="open('workExper', {}, i, index)"></i>
              <i class="el-icon-delete" @click.stop="workExperience.splice(index, 1)"></i>
            </div>
          </dl>
        </template>
        <div class="new-add" @click="open('workExper')">
          <i class="el-icon-plus"></i>增加新的工作经历
        </div>
        <dt class="title left-icon">期望岗位</dt>
        <dd>
          <el-input type="text" class="font20" v-model.trim="data.intendedPosition" :maxlength="15">
          </el-input>
          <span class="el-icon-folder-opened input-icon" @click="openSelect"></span>

          <!-- <span>办公室文员</span
          ><span>服务机器人应用技术人员</span><span>保洁员</span> -->
        </dd>

        <dd class="marked" style="display: flex">
          期望薪资：
          <div style="display: flex; color: #333333; align-items: center">
            <input placeholder="最低薪资" onkeyup="value=value.replace(/(\d{0,7})/g,'$1').match(/(\d+)/g)[0].slice(0, 7)"
              @blur="minimumPrice = $event.target.value.slice(0, 7)" style="
                background: #ffffff;
                border-radius: 4px;
                height: 32px;
                line-height: 32px;
                width: 147px;
                padding-left: 10px;
                color: #333;
                font-size: 16px;
              " v-model="minimumPrice" />
            <span style="margin-right: 6px; margin-left: 6px">至</span>
            <!-- 
									
									 onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')"
                  oninput="if(value.length > 10) value=value.slice(0, 10)"
                  @blur="minimumPrice = $event.target.value"
									 -->
            <input placeholder="最高薪资" v-model="highestPrice"
              onkeyup=" value=value.replace(/(\d{0,7})/g,'$1').match(/(\d+)/g)[0].slice(0, 7)"
              @blur="highestPrice = $event.target.value.slice(0, 7)" style="
                background: #ffffff;
                border-radius: 4px;
                height: 32px;
                line-height: 32px;
                width: 147px;
                padding-left: 10px;
                color: #333;
                font-size: 16px;
              " />
            元
          </div>
        </dd>

        <dt class="title left-icon">个人优势</dt>
        <dd style="margin-top: 6px" class="font20">
          <!-- <pack-up-text
            :text="data.personalAdvantages || ''"
            col="3"
          ></pack-up-text> -->
          <el-input type="textarea" class="font20" :rows="5" placeholder="对自我做一个简短评价，让面试效果加倍"
            v-model="data.personalAdvantages" maxlength="300">
          </el-input>

        </dd>
        <dt class="title left-icon">加分项</dt>
        <dl style="margin-bottom: 12px">
          <dt class="mini">培训经历：</dt>

          <dd>
            <div v-for="(i, j) in trainExperience" :class="'border'" :key="j + 'pp'">
              {{ i.trainingInstitutions }}
              <div class="new-operation">
                <i class="el-icon-edit" @click.stop="open('exper', {}, i, j)"></i>
                <i class="el-icon-delete" @click.stop="trainExperience.splice(j, 1)"></i>
              </div>
            </div>
          </dd>
        </dl>
        <div class="new-add" @click="open('exper')">
          <i class="el-icon-plus"></i>增加新的培训经历
        </div>
        <dl style="margin-bottom: 12px">
          <dt class="mini">语言能力：</dt>

          <dd>
            <div :class="'border'" v-for="(i, j) in languageAbility" :key="j + 'yy'">
              {{ i.languages }}{{ i.listeningSpeakingAbility }}
              <div class="new-operation">
                <i class="el-icon-edit" @click.stop="open('ability', {}, i, j)"></i>
                <i class="el-icon-delete" @click.stop="languageAbility.splice(j, 1)"></i>
              </div>
            </div>
          </dd>
        </dl>
        <div class="new-add" @click="open('ability')">
          <i class="el-icon-plus"></i>增加新的语言能力
        </div>
        <dl>
          <dt class="mini">资格证书：</dt>

          <dd>
            <div :class="'border'" v-for="(i, j) in qualification" :key="j + 'zz'">
              {{ i.certificateName }}
              <div class="new-operation">
                <i class="el-icon-edit" @click.stop="open('certify', {}, i, j)"></i>
                <i class="el-icon-delete" @click.stop="qualification.splice(j, 1)"></i>
              </div>
            </div>
          </dd>
        </dl>
        <div class="new-add" @click="open('certify')">
          <i class="el-icon-plus"></i>增加新的资格证书
        </div>
        <dl>
          <dt class="mini">专业技能：</dt>
          <dd>
            <div :class="'border'" v-for="(i, j) in professionalSkills" :key="j + 'zy'">
              {{ i.skillName }}{{ i.mastery }}

              <div class="new-operation">
                <i class="el-icon-edit" @click.stop="open('skill', {}, i, j)"></i>
                <i class="el-icon-delete" @click.stop="professionalSkills.splice(j, 1)"></i>
              </div>
            </div>
          </dd>
        </dl>
        <div class="new-add" @click="open('skill')">
          <i class="el-icon-plus"></i>增加新的专业技能
        </div>
        <dt class="flex">
          <span class="title left-icon">个人作品</span>
          <span @click.stop="getMoreProduct" class="pointer"
            v-if="(data.bonusItem.personalWorks || '').split('|').length > 3">更多<i class="el-icon-arrow-right"></i>
          </span>
        </dt>
        <dd>
          <div class="person-production" :class="''">
            <!-- <img :src="i" v-if="j <= 2" class="person-production-img" v-for="(i, j) in (data.bonusItem.personalWorks || '')
              .split('|')
              .filter((item) => item)" alt="" :key="j + 'zp'" /> -->

            <el-upload :action="$upLoad" list-type="picture-card" :limit="9" :before-upload="beforeUpload" multiple
              :on-exceed="handleExceed" :on-success="houseSuccess2" :on-remove="houseRemove2" :file-list="husPictures2">
              <i class="el-icon-plus"></i>
            </el-upload>
          </div>
        </dd>
      </dl>

      <dl class="other">
        <dt class="title left-icon">给企业留言</dt>
        <dd>
          <el-input type="textarea" class="font20" :rows="5" placeholder="主动介绍自己，让TA更快回复你哦~" v-model="data.remarks"
            maxlength="300" show-word-limit>
          </el-input>
        </dd>
        <!-- <dd style="font-size: 18px">
          <i class="el-icon-warning-outline" style="color: #64b6a8; cursor: pointer"></i>
          使用<span @click.stop="preview" style="cursor: pointer; color: #64b6a8; margin-right: 0">简历模版</span>让你的简历更加出众
        </dd> -->
      </dl>
      <!-- <dl>
        <dt>其他材料</dt>
        <dd>
          <el-upload
            :limit="3"
            list-type="picture-card"
            :show-file-list="false"
            :action="$upLoad"
          >
          </el-upload>
        </dd>
        
      </dl> -->

      <div class="xieyi">
        <el-checkbox v-model="xieyistate"></el-checkbox>
        <p>
          投递即默认同意
          <span style="color: #64b6a8; cursor: pointer" @click="toXieyi(3)">《帮帮同城用户协议》</span>
          <span style="color: #64b6a8; cursor: pointer" @click="toXieyi(2)">《帮帮同城隐私政策》</span>
        </p>
      </div>
      <div style="display: flex">
        <div class="queding" style="margin-right: 15px" @click="onSubmit">
          投递
        </div>
      </div>
      <div class="mzsm">
        {{ disclaimerContent }}
        <!-- 免责声明：帮帮同城旨在为广大用户提供更丰富的信息，但由于部分信息因时间、政策变化等因素，且信息审核会有滞后性，会导致部分信息更新不同步，与实际情况可能存在偏差，一切信息以发布方官宣为准。帮帮同城不对您交易过程中对本网站信息产生的依赖承担任何明示或默示的担保责任或任何责任。 -->
      </div>
    </div>
    <div class="resume-info-right new-start-right" v-if="data.id">
      <div class="new-start-right-title" @click="showResumeList = !showResumeList"
        style="justify-content: flex-end;text-align: right;">
        使用已经投递过的简历<span style="margin: 0 2px;font-size: 24px;"
          :class="showResumeList ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></span>
      </div>
      <div class="new-start-right-list" v-show="showResumeList">
        <div class="new-start-right-item" @click.stop="selectResume(item)" v-for="(item, index) in Recommend"
          :key="item.id">
          <div class="new-start-right-title line1">
            {{ item.resumeTitle }}
          </div>
          <div class="new-start-right-position">
            <span>{{ item.intendedPosition }}</span>
          </div>
          <div class="new-start-right-info">
            <div class="line11" style="display: flex;flex-wrap: wrap;">
              <span>{{ item.homeAddress }}</span>
              <span v-if="item.experienceYears">{{ item.experienceYears }}年工作经验</span>
            </div>
            <span style="flex-shrink: 0;padding-left: 8px;">{{ (item.highestEducation || "").split(" ")[0] }}</span>
          </div>
          <div class="new-start-right-user">
            <div>
              <img :src="item.myPhoto" alt="" v-if="item.myPhoto" />
              <span>{{ item.realName }}</span>
              <span class="vip-btn" :style="{
                color:
                  colors[(user.memberLevel || 1) - 1]
                    .wordColor,
                backgroundColor:
                  colors[(user.memberLevel || 1) - 1].bgColor,
                borderColor:
                  colors[(user.memberLevel || 1) - 1]
                    .lineColor,
              }">{{
  colors[user.memberLevel || 1 - 1].level
}}</span>
            </div>
            <div class="new-start-right-distance" v-if="item.distance">{{ item.distance }}km</div>
          </div>
        </div>
      </div>
    </div>
    <dialogContent ref="dialogContent"></dialogContent>
    <masks ref="mask" :data="data" v-if="data.bonusItem" :imgList="(data.bonusItem.personalWorks || '').split('|')">
    </masks>
    <searchPopup ref="searchPopup" @comfirm="comfirm" :index=2></searchPopup>

  </div>
</template>

<script>
import packUpText from "@/views/index/comp/packUpText.vue";
import masks from "@/views/invite/comp/mask.vue";
import inform from "@/views/index/inform";
import zcreport from "@/components/bbzc/zcreport.vue";
import dialogContent from "@/views/invite/release/comp/dialogContent.vue";
import searchPopup from "@/views/invite/release/comp/searchPopup";
import { Select } from "element-ui";

var uid = 10086
export default {
  components: {
    packUpText,
    masks,
    inform,
    zcreport,
    dialogContent,
    searchPopup,
  },
  props: {},
  data() {
    return {
      showResumeList: false,
      xieyistate: false,
      colors: [
        {
          bgColor: "#E9EFEF",
          wordColor: "#60807D",
          lineColor: "#B6C4C3",
          level: "青铜会员",
        },
        {
          bgColor: "#F7F7F7",
          wordColor: "#A3AAB0",
          lineColor: "#D2D9E0",
          level: "白银会员",
        },
        {
          bgColor: "#FFF8DE",
          wordColor: "#CEAB21",
          lineColor: "#D3CAB2",
          level: "黄金会员",
        },
        {
          bgColor: "#EDFAFF",
          wordColor: "#59B0E6",
          lineColor: "#BBD0DB",
          level: "铂金会员",
        },
        {
          bgColor: "#F2F5FF",
          wordColor: "#284EB6",
          lineColor: "#C1CBEF",
          level: "钻石会员",
        },
        {
          bgColor: "#FDF7FF",
          wordColor: "#A877C6",
          lineColor: "#DBC6E8",
          level: "钻石Ⅰ会员",
        },
        {
          bgColor: "#F8F2FF",
          wordColor: "#78439F",
          lineColor: "#958AC3",
          level: "钻石Ⅱ会员",
        },
        {
          bgColor: "#F4F2F2",
          wordColor: "#8D4581",
          lineColor: "#907B8C",
          level: "钻石Ⅲ会员",
        },
        {
          bgColor: "#F4F2F2",
          wordColor: "#502E30",
          lineColor: "#795D5E",
          level: "王者会员",
        },
      ],
      imgList: [],
      userState: 0,
      data: {
        id: "",
        // publisherId: "", //发布人ID
        resumeTitle: "", //简历标题
        myPhoto: "", //本人照片
        realName: "", //真实姓名
        sexualDistinction: "", //性别（1：男，2：女）
        dateBirth: "", //出生年月
        cellphoneNumber: "", //手机号
        workingTime: "", //参加工作时间
        highestEducation: "", //最高学历
        graduationAcademy: [], //毕业院校
        workExperience: [], //工作经历
        homeAddress: "", //家庭地址
        longitude: "", //经度
        latitude: "", //纬度
        intendedPosition: "", //意向职位
        salaryExpectation: "", //期望薪资
        personalAdvantages: "", //个人优势
        bonusItem: "", //加分项
        remarks: "",
      },
      operateList: [
        {
          imgUrl: require("@/assets/shou2.png"),
          text: "收藏信息",
          cab: "collect",
        },
        {
          imgUrl: require("@/assets/v3/resume2.png"),
          text: "获取简历",
          cab: "obtain",
        },
        {
          imgUrl: require("@/assets/v3/resume3.png"),
          text: "举报",
          cab: "report",
        },
        {
          imgUrl: require("@/assets/v3/resume4.png"),
          text: "屏蔽",
          cab: "shield",
        },
      ],
      user: {},
      tHouseInfo: {},
      indextd: "",
      Count: 0,
      weig: false,
      bUserId: "",
      businessType: "",
      qrCode: "",
      isShowPhone: false,

      // 侧边的数据栏
      param: {
        pageNo: 1,
        pageSize: 999,
        latitude: "",
        longitude: "",
      },
      Recommend: [],
      // 简历模板
      resumeTemplate: {
        enclosureWord: "",
        enclosurePdf: "",
        pictureAttachment: "",
      },
      // 薪资范围
      minimumPrice: "",
      highestPrice: "",

      //毕业院校参数
      graduationAcademy: [],
      //工作经历参数
      workExperience: [],
      // 加分项参数
      bonusItem: {},
      // 培训经历数据
      trainExperience: [],
      //语言能力数据
      languageAbility: [],
      // 资格证书数据
      qualification: [],
      // 专业技能数据
      professionalSkills: [],
      // 个人作品
      personalWorks: [],
    };
  },
  async created() {



    if (this.$route.query.userId) {
      this.userId = this.$route.query.userId;
      this.id = this.$route.query.id;
      this.index = this.$route.query.index;
      this.status = this.$route.query.status;
    }
    await this.initMap();
    this.getUser();
    this.param.userId = this.user.id;
    this.getRecommend();
    this.getHouseInfo();
    this.getDisclaimers(12); //隐私
  },
  methods: {

    houseSuccess2(response, file, fileList) {
      this.personalWorks.push({
        id: file.uid,
        path: response.data[0].url,
      });

      console.log("file", this.personalWorks);
    },
    houseRemove2(file, fileList) {
      for (var i = 0; i < this.personalWorks.length; i++) {
        if (
          this.personalWorks[i].id == file.uid ||
          this.personalWorks[i].path == file.path
        ) {
          this.personalWorks.splice(i, 1);
        }
      }
      console.log("file", this.personalWorks);
    },
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 9 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length
        } 个文件`
      );
    },
    beforeUpload(file, fileList) {
      console.log(1111111111);
      if (file.size / (1024 * 1024) > 20) {
        // 限制文件大小
        this.$message.warning(`当前限制文件大小不能大于20M`);
        return false;
      }
      let suffix = file.name.substring(file.name.lastIndexOf(".") + 1); //获取文件后缀名
      let suffixArray = ["jpg", "png", "jpeg", "gif"]; //限制的文件类型，根据情况自己定义
      if (suffixArray.indexOf(suffix.toLowerCase()) === -1) {
        this.$message({
          message: "文件格式错误",
          type: "error",
          duration: 2000,
        });
        return false;
      }
      return true;
    },
    isEqup(a, b) {
      // Internal recursive comparison function for `isEqual`.  
      var toString = Object.prototype.toString;

      function isFunction(obj) {
        return toString.call(obj) === '[object Function]'
      }

      function eq(a, b, aStack, bStack) {

        // === 结果为 true 的区别出 +0 和 -0
        if (a === b) return a !== 0 || 1 / a === 1 / b;

        // typeof null 的结果为 object ，这里做判断，是为了让有 null 的情况尽早退出函数
        if (a == null || b == null) return false;

        // 判断 NaN
        if (a !== a) return b !== b;

        // 判断参数 a 类型，如果是基本类型，在这里可以直接返回 false
        var type = typeof a;
        if (type !== 'function' && type !== 'object' && typeof b != 'object') return false;

        // 更复杂的对象使用 deepEq 函数进行深度比较
        return deepEq(a, b, aStack, bStack);
      };

      function deepEq(a, b, aStack, bStack) {

        // a 和 b 的内部属性 [[class]] 相同时 返回 true
        var className = toString.call(a);
        if (className !== toString.call(b)) return false;

        switch (className) {
          case '[object RegExp]':
          case '[object String]':
            return '' + a === '' + b;
          case '[object Number]':
            if (+a !== +a) return +b !== +b;
            return +a === 0 ? 1 / +a === 1 / b : +a === +b;
          case '[object Date]':
          case '[object Boolean]':
            return +a === +b;
        }

        var areArrays = className === '[object Array]';
        // 不是数组
        if (!areArrays) {
          // 过滤掉两个函数的情况
          if (typeof a != 'object' || typeof b != 'object') return false;

          var aCtor = a.constructor,
            bCtor = b.constructor;
          // aCtor 和 bCtor 必须都存在并且都不是 Object 构造函数的情况下，aCtor 不等于 bCtor， 那这两个对象就真的不相等啦
          if (aCtor !== bCtor && !(isFunction(aCtor) && aCtor instanceof aCtor && isFunction(bCtor) && bCtor instanceof bCtor) && ('constructor' in a && 'constructor' in b)) {
            return false;
          }
        }


        aStack = aStack || [];
        bStack = bStack || [];
        var length = aStack.length;

        // 检查是否有循环引用的部分
        while (length--) {
          if (aStack[length] === a) {
            return bStack[length] === b;
          }
        }

        aStack.push(a);
        bStack.push(b);

        // 数组判断
        if (areArrays) {

          length = a.length;
          if (length !== b.length) return false;

          while (length--) {
            if (!eq(a[length], b[length], aStack, bStack)) return false;
          }
        }
        // 对象判断
        else {

          var keys = Object.keys(a),
            key;
          length = keys.length;

          if (Object.keys(b).length !== length) return false;
          while (length--) {

            key = keys[length];
            if (!(b.hasOwnProperty(key) && eq(a[key], b[key], aStack, bStack))) return false;
          }
        }

        aStack.pop();
        bStack.pop();
        return true;

      }
      return eq(a, b);
    },
    obj2Str(obj) {
      switch (typeof (obj)) {
        case 'object':
          var ret = [];
          if (obj instanceof Array) {
            for (var i = 0, len = obj.length; i < len; i++) {
              ret.push(this.obj2Str(obj[i]));
            }
            return '[' + ret.join(',') + ']';
          }
          else if (obj instanceof RegExp) {
            return obj.toString();
          }
          else {
            for (var a in obj) {
              ret.push(a + ':' + this.obj2Str(obj[a]));
            }
            return '{' + ret.join(',') + '}';
          }
        case 'function':
          return 'function() {}';
        case 'number':
          // return obj
          return obj.toString();
        case 'string':
          // return obj
          return "\"" + obj.replace(/(\\|\")/g, "\\$1").replace(/\n|\r|\t/g, function (a) { return ("\n" == a) ? "\\n" : ("\r" == a) ? "\\r" : ("\t" == a) ? "\\t" : ""; }) + "\"";
        case 'boolean':
          return obj.toString();
        default:
          return obj.toString();
      }
    },
    // 选择职位
    openSelect() {
      this.$refs.searchPopup.open()
    },
    comfirm(lableName) {
      this.data.intendedPosition = lableName;
    },
    maxminPriceValidate() {
      if (this.salaryExpectation) {
        return true;
      }
      if (
        !this.minimumPrice ||
        !this.highestPrice ||
        +this.minimumPrice < 0 ||
        +this.highestPrice <= 0
      ) {
        this.myErrorMessage("请输入正确售价");
        return false;
      }
      console.log("1111111111111111111");
      if (+this.minimumPrice > +this.highestPrice) {
        this.myErrorMessage("最低价不能超过最高价");
        return false;
      } else {
        return true;
      }
    },
    async preview() {
      if (!this.xieyistate) {
        this.myErrorMessage("请勾选协议政策！");
        return;
      }
      this.data.graduationAcademy = this.graduationAcademy;
      // var checkStatus = this.checkData(this.data, {
      //   resumeTitle: { tip: "请填写简历标题" },
      //   // 差本人照片
      //   realName: { tip: "请填写真实姓名" },
      //   sexualDistinction: { tip: "请选择性别" },
      //   dateBirth: { tip: "请选择出生年月日" },
      //   workingTime: { tip: "请选择参加工作时间" },
      //   highestEducation: { tip: "请选择最高学历" },
      //   intendedPosition: { tip: "请选择意向职位" },
      //   salaryExpectation: { validator: this.maxminPriceValidate },
      //   graduationAcademy: { tip: "毕业院校不能为空" }
      // });
      // if (!checkStatus) return;

      let bonusItem = {
        ...this.bonusItem,
        trainExperience: JSON.stringify(this.trainExperience),
        languageAbility: JSON.stringify(this.languageAbility),
        qualification: JSON.stringify(this.qualification),
        professionalSkills: JSON.stringify(this.professionalSkills),
        personalWorks: this.personalWorks.map((item) => item.path).join("|"), // 字符串分隔的图片str
      };

      var vehicleData = {
        ...this.data,
        ...this.resumeTemplate,
        graduationAcademy: JSON.stringify(this.graduationAcademy),
        workExperience: JSON.stringify(this.workExperience),
        salaryExpectation: this.minimumPrice + "-" + this.highestPrice,
        bonusItem: JSON.stringify(bonusItem),
        // id: this.xcData.id || "",
        publisherId: this.user.id,
      };
      if (vehicleData.homeAddress) {
        // var reg = /(.*)省|([^市]*)市/g;
        // var detailedAddress = vehicleData.homeAddress;
        // var realAdd = "";
        // var temp = [];
        // while ((temp = reg.exec(detailedAddress))) {
        //   realAdd += temp[0];
        // }
        // vehicleData.homeAddress = realAdd;
      }


      localStorage.setItem("resume_preview", JSON.stringify(vehicleData));
      this.$bus.$off("addeventLisenterResumeTemplate");
      this.$bus.$on("addeventLisenterResumeTemplate", (res) => {
        console.log('resresresresres', res, this.resumeTemplate)
        this.resumeTemplate = res;
      });

      this.openUrls("/invite/resumeMoban");
    },
    // 投递
    onSubmit() {
      if (!this.xieyistate) {
        this.myErrorMessage("请勾选协议政策！");
        return;
      }
      let datas = JSON.parse(JSON.stringify(this.data));


      var checkStatus = this.checkData(datas, {
        resumeTitle: { tip: "请填写简历标题" },
        salaryExpectation: { validator: this.maxminPriceValidate },
      });
      if (!checkStatus) return;
      // if (!datas.salaryExpectation) {
      datas.salaryExpectation = this.minimumPrice + "-" + this.highestPrice;
      // }

      let bonusItem = {
        ...this.bonusItem,
        trainingExperience: JSON.stringify(this.trainExperience),
        languageAbility: JSON.stringify(this.languageAbility),
        qualification: JSON.stringify(this.qualification),
        professionalSkills: JSON.stringify(this.professionalSkills),
        personalWorks: this.personalWorks.map((item) => item.path).join("|"), // 字符串分隔的图片str
      };
      var xcData = {
        ...datas,
        ...this.resumeTemplate,
        graduationAcademy: JSON.stringify(this.graduationAcademy),
        workExperience: JSON.stringify(this.workExperience),
        bonusItem: JSON.stringify(bonusItem),
        remarks: this.data.remarks,
        publisherId: this.user.id,
      };
      var xcData2 = {
        ...datas,
        //  不要是为了比较
        graduationAcademy: this.graduationAcademy,
        workExperience: this.workExperience,
        bonusItem: {
          ...this.bonusItem,
          trainingExperience: this.trainExperience,
          languageAbility: this.languageAbility,
          qualification: this.qualification,
          professionalSkills: this.professionalSkills,
          personalWorks: this.personalWorks.map((item) => item.path).join("|"), // 字符串分隔的图片str
        },
        remarks: this.data.remarks,
        publisherId: this.user.id,
      };
      console.log(JSON.stringify(xcData2, null, 2))
      console.log(JSON.stringify(this.oldXcData, null, 2))

      if (!this.isEqup(xcData2, this.oldXcData)) {

        // xcData.auditStatus = "0"
        // alert('不同')
        // return
      } else {
        // xcData.auditStatus = 1

      }
      if (!xcData.personalAdvantages) {
        delete xcData.personalAdvantages
      }
      delete xcData.id;
      delete xcData.auditTime;
      xcData.recipient = this.userId;
      xcData.resumeId = this.id;
      xcData.deliverer = this.user.id;

      this.$postHttp("/api/mobile/personnelOwner/sendResume", xcData).then(
        (res) => {
          if (res.code == 200) {
            this.mySuccessMessage(res.msg);

            if (res.msg == "今日已投递过该岗位，请明日重试！") {
              return;
            }
            setTimeout(() => {
              this.openUrls("/invite/invitedetail", {
                id: this.$route.query.id
              });
            }, 500);
          }
        }
      );

      // checkData
    },
    // 选择历史投过的简历
    selectResume(item) {
      this.ids = item.id;
      // 重新获取简历数据
      this.getHouseInfo();
    },
    getMoreProduct() {
      this.$refs.mask.open("yulan");
    },
    // 获取定位
    initMap() {
      let data = {
        key: "ZYIBZ-6VVRW-NCURN-O6GZO-2VRAH-KIBJV",
        output: "jsonp",
      };
      return this.$jsonp(
        "https://apis.map.qq.com/ws/location/v1/ip",
        data
      ).then((data) => {
        let lat = data.result.location.lat;
        let lng = data.result.location.lng;
        // 经度
        this.param.longitude = data.result.location.lng;
        // 维度
        this.param.latitude = data.result.location.lat;
      });
    },
    // 点击举报分
    jubaoClick() {
      this.bUserId = this.data.userInformation.id;
      this.$refs.zcreport.jubaoGuan(this.$route.query.id);
    },
    // 用户信息
    getUser() {
      let user = JSON.parse(localStorage.getItem("userInfo"));
      if (user != null) {
        this.loginstate = true;
        this.user = user;
        this.$postHttp("/api/mobile/public/increaseBrowsingRecord", {
          browseRecordId: this.$route.query.id,
          viewersId: user.id,
          businessType: 4,
          browsingRecords: 7,
        }).then((res) => { });
      } else {
        this.loginstate = false;
      }
    },
    getRecommend() {
      this.$getHttp(
        "/api/mobile/personnelOwner/getDeliveryRecordTabulation",
        this.param
      ).then((res) => {
        res.deliveryRecordTabulation.pageList.forEach((v) => {
          v.active = false;
        });
        this.Recommend = this.Recommend.concat(
          res.deliveryRecordTabulation.pageList
        );
      });
    },
    async getHouseInfo(flag = false) {
      if (!this.ids) {
        this.$getHttp("/api/mobile/personnelOwner/getResumeDetails", {
          publisherId: this.user.id,
        }).then((res) => {
          if (res.code == 200) {
            //处理楼层信息
            let obj = res.biographicalNotesDetails;


            this.collectLoading = false;

            if (obj.salaryExpectation) {
              this.minimumPrice = obj.salaryExpectation.split("-")[0];
              this.highestPrice = obj.salaryExpectation.split("-")[1];
            }
            // 教育经历
            this.graduationAcademy = obj.graduationAcademy = JSON.parse(
              obj.graduationAcademy
            );

            // 工作经历
            if (obj.workExperience) {
              this.workExperience = obj.workExperience = JSON.parse(
                obj.workExperience
              );
            }
            // 加分项
            let bonusItem = JSON.parse(obj.bonusItem);
            if (obj.bonusItem) {
              obj.bonusItem = JSON.parse(obj.bonusItem);

              this.trainExperience = obj.bonusItem.trainingExperience =
                (bonusItem.trainingExperience &&
                  JSON.parse(bonusItem.trainingExperience)) ||
                [];

              this.languageAbility = obj.bonusItem.languageAbility =
                (bonusItem.languageAbility &&
                  JSON.parse(bonusItem.languageAbility)) ||
                [];

              this.qualification = obj.bonusItem.qualification =
                (bonusItem.qualification &&
                  JSON.parse(bonusItem.qualification)) ||
                [];

              this.professionalSkills = obj.bonusItem.professionalSkills =
                (bonusItem.professionalSkills &&
                  JSON.parse(bonusItem.professionalSkills)) ||
                [];
              obj.bonusItem.personalWorks = bonusItem.personalWorks
              this.personalWorks = this.manageImg(bonusItem.personalWorks).map((item) => {
                return {
                  name: uid++ + ".jpg",
                  url: item,
                  id: uid++,
                  path: item,
                };
              });
              this.husPictures2 = JSON.parse(JSON.stringify(this.personalWorks))
            }
            this.bonusItem = obj.bonusItem
            this.resumeTemplate.enclosureWord = obj.enclosureWord;
            this.resumeTemplate.enclosurePdf = obj.enclosurePdf;
            this.resumeTemplate.pictureAttachment = obj.pictureAttachment;
            // this.recoverNotNull(this.data, obj);
            this.data = JSON.parse(JSON.stringify(obj))

            this.data.personalAdvantages = this.data.personalAdvantages || ''
            this.data.bonusItem = {
              "trainingExperience": this.trainExperience,
              "languageAbility": this.languageAbility,
              "qualification": this.qualification,
              "professionalSkills": this.professionalSkills,
              "personalWorks": bonusItem.personalWorks,
            }

            this.data.publisherId = this.data.publisherId || this.user.id
            this.oldXcData = JSON.parse(JSON.stringify(this.data))

          }
        });
      } else {
        this.$getHttp(
          "/api/mobile/personnelOwner/getResumeDeliveryRecordDetails",
          {
            id: this.ids,
          }
        ).then(async (res) => {
          if (res.code == 200) {
            let uid = 10086;
            //处理楼层信息
            let obj = res.resumeDeliveryRecordDetails;



            this.collectLoading = false;
            if (obj.salaryExpectation) {
              this.minimumPrice = obj.salaryExpectation.split("-")[0];
              this.highestPrice = obj.salaryExpectation.split("-")[1];
            }
            // 教育经历
            this.graduationAcademy = obj.graduationAcademy = JSON.parse(
              obj.graduationAcademy
            );

            // 工作经历
            if (obj.workExperience) {
              this.workExperience = obj.workExperience = JSON.parse(
                obj.workExperience
              );
            }
            // 加分项
            let bonusItem = JSON.parse(obj.bonusItem);
            if (obj.bonusItem) {
              obj.bonusItem = JSON.parse(obj.bonusItem);

              this.trainExperience = obj.bonusItem.trainingExperience =
                (bonusItem.trainingExperience &&
                  JSON.parse(bonusItem.trainingExperience)) ||
                [];

              this.languageAbility = obj.bonusItem.languageAbility =
                (bonusItem.languageAbility &&
                  JSON.parse(bonusItem.languageAbility)) ||
                [];

              this.qualification = obj.bonusItem.qualification =
                (bonusItem.qualification &&
                  JSON.parse(bonusItem.qualification)) ||
                [];

              this.professionalSkills = obj.bonusItem.professionalSkills =
                (bonusItem.professionalSkills &&
                  JSON.parse(bonusItem.professionalSkills)) ||
                [];
              obj.bonusItem.personalWorks = bonusItem.personalWorks
              this.personalWorks = this.manageImg(bonusItem.personalWorks).map((item) => {
                return {
                  name: uid++ + ".jpg",
                  url: item,
                  id: uid++,
                  path: item,
                };
              });
              this.husPictures2 = JSON.parse(JSON.stringify(this.personalWorks))


            }
            this.bonusItem = obj.bonusItem
            this.resumeTemplate.enclosureWord = obj.enclosureWord;
            this.resumeTemplate.enclosurePdf = obj.enclosurePdf;
            this.resumeTemplate.pictureAttachment = obj.pictureAttachment;
            // this.recoverNotNull(this.data, obj);
            this.data = JSON.parse(JSON.stringify(obj))
            this.data.personalAdvantages = this.data.personalAdvantages || ''
            this.data.bonusItem = {
              "trainingExperience": this.trainExperience,
              "languageAbility": this.languageAbility,
              "qualification": this.qualification,
              "professionalSkills": this.professionalSkills,
              "personalWorks": bonusItem.personalWorks,
            }

            this.data.publisherId = this.data.publisherId || this.user.id,
              this.oldXcData = JSON.parse(JSON.stringify(this.data))

          }
        });
      }
    },
    open(type, type2, item, index) {
      // if (type == "gradu" && this.graduationAcademy.length > 0 && !item) {
      //   this.myErrorMessage("毕业院校只用填写最高学历院校即可！");
      //   return;
      // }
      this.$refs.dialogContent.open(type, type2, item, index);
    },
    checkData(sourceObj, operation, option) {
      var status = true;
      var value;
      var type;
      var ignoreList = option ? option.ignore || [] : [];
      for (const key in operation) {
        if (status && !ignoreList.includes(key)) {
          if (operation[key].validator) {
            status = operation[key].validator() || false;
            console.log("status", status);
          } else {
            type = Object.prototype.toString.call(sourceObj[key]);
            value = sourceObj[key];
            if (type == "[object Array]") {
              if (value.length <= 0 && operation[key]) {
                status = false;
                operation[key] &&
                  operation[key].tip &&
                  this.myErrorMessage(operation[key].tip);
              }
            } else if (type == "[object String]") {
              console.log("valuevaluevaluevaluevaluevalue", value);
              if (!(value != "") && operation[key]) {
                status = false;
                operation[key] &&
                  operation[key].tip &&
                  this.myErrorMessage(operation[key].tip);
              }
            }
          }
        }
      }
      return status;
    },
    /**
     * 表单对象赋值:
     * 对目标对象存在且源对象同样存在的属性，全部覆盖；
     * 目标对象不存在但是源对象存在的属性， 全部丢弃；
     * 目标对象存在但是源对象不存在的属性，保留目标对象的属性不做处理
     */
    // recoverNotNull(target, source) {
    //   if (target === undefined || target === null) {
    //     throw new TypeError("Cannot convert first argument to object");
    //   }
    //   var to = Object(target);
    //   if (source === undefined || source === null) {
    //     return to;
    //   }
    //   var keysArray = Object.keys(Object(target));
    //   for (
    //     var nextIndex = 0, len = keysArray.length;
    //     nextIndex < len;
    //     nextIndex++
    //   ) {
    //     var nextKey = keysArray[nextIndex];
    //     var desc = Object.getOwnPropertyDescriptor(target, nextKey);
    //     if (desc !== undefined && desc.enumerable) {
    //       if (to.hasOwnProperty(nextKey)) {
    //         if (to[nextKey] instanceof Array) {
    //           to[nextKey] = source[nextKey];
    //         } else if (to[nextKey] instanceof Object) {
    //           recover(to[nextKey], source[nextKey]);
    //         } else if (source[nextKey] !== undefined) {
    //           to[nextKey] = source[nextKey];
    //         }
    //       }
    //     }
    //   }
    //   return to;
    // },
    chat() { },
  },
};
</script>

<style lang="less" scoped>
@bgc: rgba(100, 182, 168, 0.3) !important;
@bgcg: rgba(196, 196, 196, 0.1) !important;

@color: rgba(100, 182, 168, 1) !important;
@br: 4px;
@pd: 5px 0;

.font20 {
  font-size: 20px !important;
  font-weight: 400 !important;
}

.border {
  position: relative;
  // border: 1px solid @bgc;
  border-radius: @br;
  padding: @pd;
  transition: all 0.3s;
  padding-right: 92px;
  outline: none;

  &:hover {
    outline: 1px solid @color;
  }

  &+.border {
    margin-top: 12px;
  }
}

.editabled {
  input {
    &:hover {
      outline: 1px solid @color;
    }
  }

  /deep/ .el-input__inner {
    padding-left: 0px;
    outline: none;
    border: none;
    // background-color: @bgc;
    background-color: @bgcg;
    border-radius: @br;

    &:hover {
      outline: 1px solid @color;
    }
  }

  /deep/ .el-textarea__inner {
    padding-left: 0px;
    outline: none;
    border: none;
    background-color: @bgcg;

    &:hover {
      outline: 1px solid @color;
    }

    // background-color: @bgc;
  }

  input {
    // background-color: @bgc;
    background-color: @bgcg;

  }

  // 新增
  .new-add {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-top: 12px;
    color: @color;

    i {
      font-size: 16px;
      font-weight: 600;
      margin-right: 10px;
    }
  }

  dd {
    position: relative;

    .input-icon {
      position: absolute;
      top: 50%;
      right: 0;
      transform: translateY(-50%);
      cursor: pointer;
      font-size: 28px;
      color: @bgc;
      transition: all 0.3s;

    }

    &:hover {
      .input-icon {
        color: @color;
      }

    }
  }

  // 编辑
  .new-operation {
    display: flex;
    position: absolute;
    right: 20px;
    top: 8px;
    font-size: 24px;
    font-weight: 600;

    i {
      transition: all 0.3s;
      color: @bgc;

      cursor: pointer;

      &:not(:first-child) {
        margin-left: 10px;
      }

      // &:hover {
      //   color: @color;
      // }
    }
  }

  .border {
    &:hover {
      .new-operation {
        i {
          color: @color;

        }
      }

    }
  }

}



.left-icon {
  position: relative;
  height: 28px !important;
  font-size: 22px !important;
  font-weight: 500 !important;
  color: #333333 !important;
  line-height: 28px !important;
  padding-left: 10px;

  &::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translate(0, -50%);
    left: 0;
    width: 4px;
    height: 22px;
    background: #64B6A8;
    border-radius: 3px 3px 3px 3px;
    opacity: 1;
  }
}

// 违规
.weigui {
  position: absolute;
  z-index: 99;
  padding: 0px 10px 0px 10px;
  width: 300px;
  right: -240px;
  bottom: 122px;

  .img {
    width: 100%;
    height: 134rpx;

  }

  p {
    position: absolute;
    left: 50px;
    bottom: 26px;
    font-size: 16px;
    color: #fff;
  }
}

.resume-info {
  width: 1200px;
  margin: 0 auto;
  padding-top: 37px;
  display: flex;

  .resume-info-left {
    width: 794px;

    .resume-title {
      height: 28px;
      font-size: 22px;
      font-weight: 500;
      color: #333333;
      line-height: 28px;
    }

    .resume-user-info {
      position: relative;
      margin-top: 41px;
      display: flex;
      justify-content: space-between;

      .resume-user-left {
        font-size: 20px;
        font-weight: 400;
        color: #333333;
        line-height: 28px;

        .resume-user-detail {
          span {
            &:first-child {
              margin-right: 32px;
            }
          }
        }

        .resume-user-ex {
          margin-top: 12px;
        }

        .resume-user-add {
          margin-top: 12px;
          margin-bottom: 10px;
        }
      }

      .resume-user-right {
        width: 80px;
        height: 80px;
        margin-bottom: 12px;
        background: #d9d9d9;
        opacity: 1;
        border-radius: 50%;
      }
    }

    .seperate {
      width: 794px;
      height: 0px;
      opacity: 1;
      border: 1px solid #dcdcdc;
    }

    dl {
      font-size: 20px;
      font-weight: 400;
      color: #333333;
      line-height: 28px;
      position: relative;

      .title {}

      dt {
        margin-top: 48px;
        height: 28px;
        font-size: 22px;
        font-weight: 500;
        color: #333333;
        line-height: 28px;

        &.mini {
          margin-top: 24px;
        }
      }

      dd {
        margin-top: 10px;

        /deep/ .texttext {
          font-size: 20px;
        }

        span {
          margin-right: 20px;
        }
      }

      .marked {
        margin-top: 20px;

        span {
          font-size: 20px;
          font-weight: 500;
          color: #333333;
        }
      }

      .flex {
        display: flex;
        justify-content: space-between;
        align-items: center;

        span {
          font-size: 20px;
          font-weight: 400;
          color: #64b6a8;

          .el-icon-arrow-right {}
        }
      }
    }

    .person-production {
      width: 100%;
      margin-top: 10px;

      .person-production-img {
        width: calc((100% - 60px) / 4);

        // width: 184px;
        height: 184px;
        background: #d9d9d9;
        border-radius: 0px 0px 0px 0px;
        margin-bottom: 60px;
        opacity: 1;

        &:not(:last-child) {
          margin-right: 20px;
        }
      }
    }
  }

  .mzsm {
    width: 1200px;
    margin: 0 auto;
    font-size: 12px;
    line-height: 18px;
    color: #aaa;
    margin-top: 10px;
    width: 97%;
    margin-top: 15px;
    margin-bottom: 130px;
  }

  .resume-info-right {
    width: 362px;
    padding-left: 40px;

    .operate-list {
      display: flex;
      // flex-wrap: wrap;
      text-align: center;

      .operate-item {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        width: 96px;
        margin-bottom: 12px;
        cursor: pointer;

        &:nth-child(n + 3) {
          // margin-bottom: 26px;
        }

        img {
          width: 40px;
          height: 40px;
        }

        span {
          height: 28px;
          font-size: 20px;
          font-weight: 400;
          color: #333333;
          line-height: 28px;
        }
      }
    }

    .miniprogram {
      width: 272px;
      text-align: center;

      img {
        width: 272px;
        height: 272px;
        border-radius: 0px 0px 0px 0px;
        opacity: 1;
      }

      div {
        margin-top: 12px;
        height: 28px;
        font-size: 20px;
        font-weight: 400;
        color: #333333;
        line-height: 28px;
      }
    }

    .but {
      margin-top: 26px;
      display: flex;
      margin-bottom: 46px;

      div {
        position: relative;
        display: inline-block;
        //width: 153px;
        height: 51px;
        border-radius: 4px;
        overflow: hidden;
        text-align: center;
        line-height: 51px;
        text-indent: 50px;
        color: #fff;
        margin-right: 15px;

        img {
          position: absolute;
          width: 33px;
          height: 33px;
          top: 9px;
          left: 25px;
        }
      }

      p {
        margin-left: 10px;
      }

      .but_1 {
        cursor: pointer;
        padding-right: 20px;
        background: rgba(100, 182, 168, 0.14);
        color: #64b6a8;
      }

      .but_2 {
        cursor: pointer;
        padding-right: 20px;
        background: #64b6a8;
      }
    }
  }
}

.new-start-right {
  width: 488px;

  .new-start-right-title {
    height: 34px;
    font-size: 24px;
    font-weight: 500;
    color: #64b6a8;
    line-height: 28px;
    margin-bottom: 16px;
    text-align: left;
    cursor: pointer;
  }

  .new-start-right-list {
    .new-start-right-item {
      margin-top: 6px;
      border-bottom: 1px solid #64b6a8;
      text-align: left;

      div {
        margin-bottom: 8px;
      }

      .new-start-right-title {
        height: 28px;
        font-size: 20px;
        font-weight: 500;
        color: #333333;
        line-height: 28px;
      }

      .new-start-right-position {
        height: 28px;
        font-size: 20px;
        font-weight: 400;
        color: #333333;
        line-height: 28px;

        span:not(:last-child) {
          margin-right: 6px;
        }
      }

      .new-start-right-info {
        display: flex;
        justify-content: space-between;

        div {
          // height: 28px;
          font-size: 20px;
          font-weight: 400;
          color: #333333;
          line-height: 28px;
          display: flex;

          margin-bottom: 0;
        }

        span {
          font-size: 20px;
          font-weight: 400;
          color: #333333;
        }
      }

      .new-start-right-user {
        color: #333;
        display: flex;
        justify-content: space-between;

        div {
          margin-bottom: 0;
          display: flex;
          align-items: center;
        }

        img {
          width: 30px;
          height: 30px;
          border-radius: 50%;
          background: #d9d9d9;
          opacity: 1;
        }

        .vip-btn {

          white-space: nowrap;
          padding: 3px 6px;
          height: 24px;
          border-radius: 2px 2px 2px 2px;
          opacity: 1;
          border: 1px solid #64b6a8;
          // width: 56px;
          height: 20px;
          font-size: 14px;
          font-weight: 400;
          color: #64b6a8;
          line-height: 22px;
          border-radius: 4px;
          text-align: center;
          margin-left: 6px;
          vertical-align: middle;
        }

        .new-start-right-distance {
          height: 28px;
          font-size: 20px;
          font-weight: 400;
          color: #999999;
          line-height: 28px;
        }
      }
    }
  }
}

.xieyi {
  width: 550px;
  color: #333;
  // margin-left: 50%;
  // transform: translateX(-50%);
  margin-top: 70px;
  margin-bottom: 25px;

  /deep/.el-checkbox__inner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
  }

  /deep/.el-checkbox__inner::after {
    border: 2px solid #fff;
    width: 6px;
    height: 13px;
    left: 9px;
    top: 4px;
    border-left: 0;
    border-top: 0;
  }

  /deep/.el-checkbox__input.is-checked .el-checkbox__inner,
  /deep/.el-checkbox__input.is-indeterminate .el-checkbox__inner {
    background-color: #64b6a8;
    border-color: #64b6a8;
  }

  p {
    width: 450px;
    display: inline-block;
  }
}

.queding {
  width: 300px;
  height: 60px;
  background: #64b6a8;
  border-radius: 6px;
  text-align: center;
  line-height: 60px;
  font-size: 24px;
  margin-bottom: 50px;
  cursor: pointer;
}
</style>
